package org.jeecg.modules.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.base.entity.SysUserTit;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.modules.service.StudentInformationservice;
import org.jeecg.modules.student_course.service.IAstuUserCourseService;
import org.jeecg.modules.vo.CourseInformation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @ClassName:StudentInformationcontroller
 * @Description: TODO
 * @author: wang yue niao
 * @date 2020/11/6 15:51
 * @Version 1.0
 */
@Slf4j
@Api(tags="学生实验成绩接口")
@RestController
@RequestMapping("/StudentInformationcontroller")
public class StudentInformationcontroller {
    @Autowired
    private StudentInformationservice studentInformationservice;
    @Autowired
    private ISysBaseAPI iSysBaseAPI;

    @ApiOperation("查询实验成绩")
    @RequestMapping(value = "/getinformation", method = RequestMethod.POST)
    public Result<JSONObject> login(HttpServletRequest request) {
        Result<JSONObject> result = new Result<>();
        //获取token
        String token = request.getHeader("X-Access-Token");
        //获取当前登录用户的unionid username就是学号或者工号
        String username = JwtUtil.getUsername(token);
        SysUserTit user = iSysBaseAPI.getUser(username);
        String id = user.getId();

        List<CourseInformation> experimentByUserid = studentInformationservice.getExperimentByUserid(id);
        JSONObject obj = new JSONObject();
        obj.put("experimentByUserid", experimentByUserid);
        result.setResult(obj);
        result.success("成功");
        return result;
    }



}
